package com.hdax.service.Impl;

import com.hdax.entity.EmployeeInfo;
import com.hdax.entity.Role;
import com.hdax.mappers.RoleMapper;
import com.hdax.service.RoleService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 角色服务impl
 *
 * @author Aizen
 * @date 2022/05/04
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Autowired
    private EmployeeInfoServiceImpl employeeInfoService;


    @Override
    public List<Role> findAllRoles(int page,int limit,Role role) {
        return roleMapper.findAllRoles(page, limit, role);
    }

    @Override
    public int addRole(Role role) {
        String roleCode = employeeInfoService.toPinyin(role.getDescription());
        //角色code
        role.setRole(roleCode);
        return roleMapper.addRole(role);
    }

    @Override
    public int deleteRole(Integer roleId) {
        return roleMapper.deleteRole(roleId);
    }

    @Override
    public int findCountByRole(Integer roleId) {
        return roleMapper.findCountByRole(roleId);
    }

    @Override
    public int updateRole(Role role) {
        return roleMapper.updateRole(role);
    }

    @Override
    public Role setByName(String description) {
        return roleMapper.setByName(description);
    }

    @Override
    public List<Role> roels(int departmentId) {
        return roleMapper.roels(departmentId);
    }

    @Override
    public Role findIdByDepartmentId(Integer id) {
        return roleMapper.findIdByDepartmentId(id);
    }

    @Override
    public Role findIdByDepartmentId2(Integer id) {
        return roleMapper.findIdByDepartmentId2(id);
    }

    @Override
    public Integer findCount() {
        return roleMapper.findCount();
    }

    @Override
    public void deleteroleByDepartmentId(Integer depId) {
        roleMapper.deleteroleByDepartmentId(depId);
    }

    @Override
    public List<Role> findAll() {
        return roleMapper.findAll();
    }

    @Override
    public Role findById(int id) {
        return roleMapper.findById(id);
    }
}
